package foundation;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

/**
 * <h1></h1>
 *
 * @author zhh 2019-05-30
 */
public class ReadGson {
    public static void main(String[] args) {
        String json = "{\"name\":\"jean\",\"age\":16,\"birthday\":\"2010-03-01\",\"hobby\":[\"sing\",\"dance\"],\"createTime\":\"2019-05-30\",\"score\":[85,90,100]}";
        Gson gson = new Gson();
        Student student = gson.fromJson(json, Student.class);
        System.out.println(student);
        System.out.println(student.getName());
        System.out.println("----------");
        Gson gson1 = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        student = gson1.fromJson(json, Student.class);
        System.out.println(student.getCreateTime().toInstant());
        System.out.println(student.getScore());
        System.out.println(student.getScore().getClass());
    }
}
